﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;
using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.Windows;

namespace DarkLight.Model
{
    [DataContract]
    public abstract class SpaceObject : ObservableObject, IPosition
    {                
        public bool IsRelativePosition
        {
            get
            {
                return ParentOrthonormality is IOrthonormality;
            }
        }

        public Spherical Position
        {
            get { return _position; }
            set
            {
                if (!object.ReferenceEquals(_position, value))
                {
                    RaisePropertyChanging("Position");
                    _position = value;
                    RaisePropertyChanged("Position");
                }
            }
        }
        private Spherical _position = Spherical.Zero;

        public IOrthonormality ParentOrthonormality
        {
            get { return _parentOrthonormality; }
            set
            {
                if (!object.ReferenceEquals(_parentOrthonormality, value))
                {
                    RaisePropertyChanging("ParentOrthonormality");
                    _parentOrthonormality = value;
                    RaisePropertyChanged("ParentOrthonormality");
                }
            }
        }
        private IOrthonormality _parentOrthonormality;

        public Spherical AbsolutePosition
        {
            get
            {
                return IsRelativePosition ? 
                    (ParentOrthonormality as IOrthonormality).AbsolutePosition + this.Position :
                    this.Position;
            }
        }

    }
}
